<?php

/**
 * @author edson
 * @copyright 2011
 *  
 */

 //establecer una variable conratafisica $_LOCALHOST
$ruta=$_SERVER['DOCUMENT_ROOT']."/viventura"."/MDOperator";
include_once("$ruta/star.php");
//include_once("$rut/conf/CConfig.php");

$valor = "";
$idTour=NULL;
$idOpe=$_POST['idOpe'];
$idOfi=$_POST['idOfi'];
$multiple=$_POST['multi'];
//var_dump($multiple);
	
foreach($multiple as $r=>$c){$valor=$valor.$c.",";}
        $valor= substr($valor,0,strlen($valor)-1);


$paquete="insert into pack (IdPack,OFICINAS_idOfi) values ('NULL','$idOfi')";
$paqueteId=CModelo::getInstance()->insertData($paquete);
//echo $paqueteId;

//creando el tour default
$tour="insert into tour (idTour) values ('NULL')";
$tourId=CModelo::getInstance()->insertData($tour);
//echo $tourId;

//relacionando el default tour del paquete
$packtour="insert into pack_has_tour (idPackTour,PACK_idPack,TOUR_idTour,DefaultTourPack) values ('NULL','$paqueteId','$tourId','1')";
$idPackTour = CModelo::getInstance()->insertData($packtour);
//echo $idPackTour;

//relacionando las extensiones con el defaulttourPACK

foreach($multiple as $r=>$extension){
    $extPack="insert into pack_has_tour_has_extensiones (idExtTour,pack_has_tour_idPackTour,extensiones_idExt,operador_idOpe) values ('NULL',$idPackTour,$extension,$idOpe)";
    $idExtPack = CModelo::getInstance()->insertData($extPack);
    echo $idExtPack.",";
  }
       
        



//Registrando extensiones



//-------------------------------------------------
//validacion de usuarios 

///$cadena="insert into tour (IdTour, OriTour, DestTour, PriTour, MinPaxTour, MaxPaxTour ) values ('NULL','$OriTour', '$DestTour', '$PriTour', '$MinPaxTour', '$MaxPaxTour')";
//$insertId=CModelo::getInstance()->insertData($cadena);

    
  
//include_once("$rut/elements/head.tpl");
include_once("$rut/elements/foot.tpl");








?>